//
//  WLTabBarController.m
//  e律师
//
//  Created by 韦淋 on 2017/5/15.
//  Copyright © 2017年 test. All rights reserved.
//

#import "WLTabBarController.h"

#import "MessageViewController.h"
#import "ContactViewController.h"
#import "ApplyViewController.h"
#import "MeViewController.h"

#import "WLCustomTabBar.h"
#import "UIView+Extension.h"

@interface WLTabBarController ()
//@property(nonatomic,strong)UIView *zheZhaoView;
//
//@property(nonatomic,strong)NSMutableArray *btnArr;
//
//@property(nonatomic,strong)UIButton *closeBtn;
@end

@implementation WLTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    MessageViewController *messageVC = [[MessageViewController alloc] init];
    [self setChildVC:messageVC title:@"消息中心" image:@"消息1" selectedImage:@"消息2"];
    
    ContactViewController *contactVC = [[ContactViewController alloc] init];
    [self setChildVC:contactVC title:@"司法通信录" image:@"联系法官1" selectedImage:@"练习法官2"];
    
    ApplyViewController *applyVC = [[ApplyViewController alloc] init];
    [self setChildVC:applyVC title:@"应用工具" image:@"应用1" selectedImage:@"应用2"];
    
    MeViewController *meVC = [[MeViewController alloc] init];
    [self setChildVC:meVC title:@"个人中心" image:@"我1" selectedImage:@"我2"];
    
    WLCustomTabBar *customTabBar = [[WLCustomTabBar alloc] init];
    [self setValue:customTabBar forKey:@"tabBar"];
    
}

- (void) setChildVC:(UIViewController *)childVC title:(NSString *) title image:(NSString *) image selectedImage:(NSString *) selectedImage {
    
    childVC.tabBarItem.title = title;
    childVC.navigationItem.title = title;
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    dict[NSForegroundColorAttributeName] = [UIColor blackColor];
    dict[NSFontAttributeName] = [UIFont systemFontOfSize:10];
    [childVC.tabBarItem setTitleTextAttributes:dict forState:UIControlStateNormal];
    childVC.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    childVC.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        [self addChildViewController:childVC];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:childVC];
    [self addChildViewController:nav];
}


@end
